package com.zzptc.fxh.myapplication;

import android.content.Context;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;

import java.util.ArrayList;
import java.util.Map;


public class FristFragment extends Fragment {
    private LineChart lineChart;
    // TODO: Rename parameter arguments, choose names that match

    public FristFragment() {
    }

    public static FristFragment newInstance(String param1, String param2) {
        FristFragment fragment = new FristFragment();
        Bundle args = new Bundle();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_frist, container, false);
        lineChart = view.findViewById(R.id.line_Chart);
        ArrayList<Entry> list1=new ArrayList<>();
        list1.add(new Entry(1,3));
        list1.add(new Entry(2,8));
        list1.add(new Entry(3,6));
        list1.add(new Entry(4,4));
        list1.add(new Entry(5,3));
        LineDataSet lineDataSet=new LineDataSet(list1,null);
        lineDataSet.setColor(Color.BLUE);

        ArrayList<Entry> list2=new ArrayList<>();
        list2.add(new Entry(1,9));
        list2.add(new Entry(2,5));
        list2.add(new Entry(3,8));
        list2.add(new Entry(4,1));
        list2.add(new Entry(5,5));
        LineDataSet lineDataSet1=new LineDataSet(list2,null);
        lineDataSet.setColor(Color.GREEN);

        ArrayList<ILineDataSet> list_lineDataSet=new ArrayList<>();
        list_lineDataSet.add(lineDataSet);
        list_lineDataSet.add(lineDataSet1);

        LineData lineData=new LineData(list_lineDataSet);

        lineChart.setData(lineData);
        XAxis xAxis=lineChart.getXAxis();
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        // Inflate the layout for this fragment
        return view;
    }
}
